<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title><block name="title">后台</block></title>
    <include file="./Common/View/Public/layui.html" />
    <block name="style"></block>
    <include file="./Common/View/Public/header.html" />
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <include file="./Common/View/Public/nav.html" />
    <include file="./Common/View/Public/menu.html" />
    <div class="layui-body">
        <div style="padding: 15px;">
            <fieldset class="layui-elem-field layui-field-title mt-15">
                <legend><block name="page_title"></block></legend>
            </fieldset>
            <div class="layui-row">
                <div class="layui-col-xs12 layui-col-md8">
                    <block name="main">
                        <form class="layui-form" method="post" action="{:strtolower(__INFO__)}" lay-filter="pageForm">
                            <div class="layui-form-item">
                                <label class="layui-form-label">模板文件</label>
                                <div class="layui-input-inline">
                                    <a href="__PUBLIC__/excel/{:strtolower(CONTROLLER_NAME)}.xlsx" target="_blank">{:strtolower(CONTROLLER_NAME)}.xlsx</a>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">数据文件</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="excel" id="excel" lay-verify="required" placeholder="请选择文件后上传" autocomplete="off" class="layui-input" />
                                </div>
                                <div class="layui-form-mid layui-word-aux"><button class="layui-btn layui-btn-sm" type="button" id="fileBtn">浏览</button></div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">冲突处理</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="exists" value="1" title="报错" checked>
                                    <input type="radio" name="exists" value="2" title="跳过">
                                    <input type="radio" name="exists" value="3" title="覆盖">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">错误处理</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="error" value="1" title="退出" checked>
                                    <input type="radio" name="error" value="2" title="继续">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="pageForm">立即提交</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </div>
                        </form>
                    </block>
                </div>
            </div>
        </div>
    </div>
    <include file="./Common/View/Public/footer.html" />
</div>
<script src="__PUBLIC__/sys/app.js"></script>
<script src="__PUBLIC__/sys/form.js"></script>
<block name="script">
    <script>
        layui.use('upload', function() {
            var upload = layui.upload;
            upload.render({ //允许上传的文件后缀
                elem: '#fileBtn'
                ,url: app.api + 'sys/upload/excel'
                ,accept: 'file' //普通文件
                ,exts: 'xls|xlsx|' //只允许上传压缩文件
                ,done: function(res, index, upload){
                    if(res.error ==  '0'){
                        $('#excel').val(res.data);
                    }else{
                        app.error(res.message);
                    }
                }
                ,error: function(index, upload){
                    app.error("上传文件发生错误!");
                }
            });
        });
    </script>
</block>
</body>
</html>